﻿@{
    Layout = null;
    var tree = ViewData["tree"] as List<System.Domain.Entities.Menu>;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>天泽电子物料管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="~/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="~/layuiadmin/style/admin.css" media="all">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <style>
        .fa {
            left: 20px;
            top: 30%;
            position: absolute;
        }
    </style>
</head>
<body class="layui-layout-body">
    <div class="modal-body" style="display:none">
        <form class="layui-form" name="changeform" method="post" style="padding-top:20px;">
            <div class="layui-form-item">
                <label class="layui-form-label">原密码 *</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="password" id="old_password" name="old_password" lay-verify="required" autocomplete="off" lay-reqtext="请输入原密码" placeholder="原密码">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码 *</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="password" id="new_password" name="new_password" lay-verify="required|pass" autocomplete="off" lay-reqtext="请输入新密码" placeholder="新密码">
                    <span style="color:red;font-size:10px;">密码长度不得小于8位，且需包含数字、大小写字母与特殊字符</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认新密码 *</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="password" id="new_passwordcheck" name="new_passwordcheck" lay-verify="required|pass" autocomplete="off" lay-reqtext="请确认新密码" placeholder="新密码">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <a class="layui-btn layui-block btn-submit" lay-filter="change" lay-submit>确认</a>
                </label>

            </div>
        </form>
    </div>
    <div id="LAY_app">
        <div class="layui-layout layui-layout-admin">
            <div class="layui-header">
                <!-- 头部区域 -->
                <ul class="layui-nav layui-layout-left">
                    <li class="layui-nav-item layadmin-flexible" lay-unselect>
                        <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                            <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;" layadmin-event="refresh" title="刷新">
                            <i class="layui-icon layui-icon-refresh-3"></i>
                        </a>
                    </li>
                </ul>
                <ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right">
                    @*<li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="https://docs.qq.com/doc/DVmxiV01rakR2eUFO" target="_blank" title="系统帮助文档">
                    <i class="layui-icon layui-icon-help"></i>
                    </a>
                    </li>*@
                    <li class="layui-nav-item layui-hide-xs" lay-unselect title="记录便签">
                        <a href="javascript:;" layadmin-event="note">
                            <i class="layui-icon layui-icon-note"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item layui-hide-xs" lay-unselect>
                        <a href="javascript:;" layadmin-event="fullscreen">
                            <i class="layui-icon layui-icon-screen-full"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;">
                            <cite></cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd><a id="updatepwd">修改密码</a></dd>
                            <hr />
                            <dd onclick="location.href='/Login/LoginOut'" style="text-align: center;cursor:pointer;"><a>退出</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
            <!-- 侧边菜单 -->
            <div class="layui-side layui-side-menu">
                <div class="layui-side-scroll">
                    <div class="layui-logo" style="height: 100px;" lay-href="/Home/IndexCount">
                        <div><img src="/favicon.ico" style="max-width: 50px;max-height: 50px;" /></div>
                        <span>天泽电子物料管理系统</span>
                    </div>
                    <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" style="margin-top: 100px;" lay-filter="layadmin-system-side-menu">
                        @for (int i = 0; i < tree.Count; i++)
                        {
                            <li data-name="home" class="layui-nav-item">
                                <a href="javascript:;" lay-tips="@tree[i].name" @(tree[i].child!=null ? "" : "lay-href='" + tree[i].url + "'") lay-direction="2">
                                    <i class="@tree[i].icon"></i>
                                    <cite>@tree[i].name</cite>
                                </a>
                                @if (tree[i].child!=null)
                                {
                                    <dl class="layui-nav-child">
                                        @for (int j = 0; j < tree[i].child.Count; j++)
                                        {
                                            <dd data-name="@tree[i].child[j].name">
                                                <i class="@tree[i].child[j].icon"></i>
                                                <a lay-href="@tree[i].child[j].url">@tree[i].child[j].name</a>
                                            </dd>
                                        }

                                    </dl>
                                }
                            </li>
                        }
                    </ul>
                </div>
            </div>

            <!-- 页面标签 -->
            <div class="layadmin-pagetabs" id="LAY_app_tabs">
                <div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
                <div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
                <div class="layui-icon layadmin-tabs-control layui-icon-down">
                    <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                        <li class="layui-nav-item" lay-unselect>
                            <a href="javascript:;"></a>
                            <dl class="layui-nav-child layui-anim-fadein">
                                <dd layadmin-event="closeThisTabs"><a href="javascript:;">关闭当前标签页</a></dd>
                                <dd layadmin-event="closeOtherTabs"><a href="javascript:;">关闭其它标签页</a></dd>
                                <dd layadmin-event="closeAllTabs"><a href="javascript:;">关闭全部标签页</a></dd>
                            </dl>
                        </li>
                    </ul>
                </div>
                <div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                    <ul class="layui-tab-title" id="LAY_app_tabsheader">
                        <li lay-id="home/console.html" lay-attr="home/console.html" class="layui-this"><i class="layui-icon layui-icon-home"></i></li>
                    </ul>
                </div>
            </div>
            <!-- 主体内容 -->
            <div class="layui-body" id="LAY_app_body">
                <div class="layadmin-tabsbody-item layui-show">
                    <iframe src="/Home/IndexCount" frameborder="0" class="layadmin-iframe"></iframe>
                </div>
            </div>

            <!-- 辅助元素，一般用于移动设备下遮罩 -->
            <div class="layadmin-body-shade" layadmin-event="shade"></div>
        </div>
    </div>
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/layuiadmin/layui/layui.js"></script>
  
    <script>
        layui.config({
            base: '/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            $("#updatepwd").click(function () {
                layer.open({
                    shadeClose: true,
                    title: "修改密码",
                    type: 1,
                    content: $(".modal-body"),
                    area: ['450px', '320px'],
                });
            })
            //自定义验证规则
            form.verify({
                pass: [
                    /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,}$/
                    , '密码长度不得小于8位，且需包含数字、大小写字母与特殊字符'
                ]
            });
            form.on("submit(change)", function (data) {
                var form = document.forms["changeform"];

                var old_password = form.elements["old_password"].value;
                var new_password = form.elements["new_password"].value;
                var new_passwordcheck = form.elements["new_passwordcheck"].value;
                if (new_password != new_passwordcheck) {
                    layer.msg("两次输入密码不一致,请重新输入");
                    return;
                }

                var parms = new Object();
                parms["oldpwd"] = old_password;
                parms["new_password"] = new_password;

                $.post("/Login/ChangePwd", parms, function (data) {
                    if (data.state == 1) {
                        layer.msg(data.message, function () {
                            window.location.href = '/Login/LoginOut';
                        });
                    } else {
                        layer.msg(data.message);
                    }
                })
            })

        });

    </script>

</body>
</html>